/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rehab.host.gui;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;


/**
 *
 * @author shahsant
 */

public class GCanvas extends JPanel{

    public int xCord, yCord, xCord2, yCord2;
    BasicStroke wideStroke,fineStroke;
    GradientPaint gradient;

    public GCanvas() {
        xCord = yCord =0;
        //setOpaque(false);
        gradient = new GradientPaint(30, 50, Color.blue, 100, 100, Color.red, true);
        wideStroke = new BasicStroke(2);
        fineStroke = new BasicStroke(1);
        setVisible(true);
        repaint();
    }
    
    public void setCord(int x, int y){
        xCord = x;
        yCord = y;
        //repaint();
    }

     public void setCord(int x, int y, int x2){
       // xCord = x;
       // yCord = y;
        xCord2 = x2;
        repaint();
    }

    public void paintComponent(Graphics g){
         Graphics2D g2D = (Graphics2D) g;
        drawRect(g2D, xCord, xCord2);
    }



    public void paint(Graphics g){
       Graphics2D g2D = (Graphics2D) g;
       g2D = (Graphics2D) g;
       g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
       g2D.setStroke(wideStroke);
       g2D.setColor(Color.red);
     //  g2D.s
       drawLine(g2D, xCord, yCord);
      // drawLine(g2D, 50, 200, 350, 300);
//       g2D.setStroke(wideStroke);
//       g2D.setPaint(gradient);
//       fillRect(g2D, 30, 50, 300, 100);
       //drawEllipse(g2D, 30, 50, 300, 100);
       //drawArc(g2D, 30, 250, 300, 100, 0, 45, Arc2D.CHORD);
    }

    public void drawLine(Graphics2D g2D, int x1, int y1){
        g2D.drawLine(x1,0,x1,this.getHeight());

    }
    public void drawRect (Graphics2D g2D, int x1, int x2){
        g2D.drawRect(x1, 0, x2, this.getHeight());
    }
//
//    public void fillRect(Graphics g2D, int x1, int y1, int x2, int y2){
//        Rectangle2D.Float rect1 = new Rectangle2D.Float(x1, y1, x2, y2);
//        g2D.fillRect(x1,y1,x2,y2);
//    }

//    public void drawArc(Graphics2D g2D, int x1, int y1, int x2, int y2, int sd, int rd, int cl){
//        Arc2D.Float arc1 = new Arc2D.Float(x1, y1, x2, y2, sd, rd, cl);
//        g2D.fill(arc1);
//    }
//
//    public void drawEllipse(Graphics g2D, int x1, int y1, int x2, int y2){
//        Ellipse2D.Float oval1 = new Ellipse2D.Float(x1, y1, x2, y2);
//        g2D.fillOval(x1, y1, x2, y2);
//    }
//
}

